import {Directive, Input,ElementRef,OnInit} from '@angular/core';

@Directive({
  selector: '[appChangeBg]'
})
export class ChangeBgDirective implements OnInit{
  @Input appChangeBg="";
  constructor(private elemRef:ElementRef) { }
  ngOnInit(){
    //获取到传来的颜色 并修改调用指令元素的背景色
    this.elemRef.nativeElement.style.backgroundColor=this.appChangeBg
  }
}
